package json;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import flexjson.JSONSerializer;
import flexjson.transformer.DateTransformer;

public class JsonTest2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Date d = new Date();
		Timestamp t = new Timestamp(d.getTime());
		Map<String, Object> map = new HashMap<String, Object>();
		List<Object> list = new ArrayPageList<Object>();
		UserBean user = new UserBean();
		user.setUserID("123");
		user.setUserName("helen");
		user.setBirthday(d);
		user.setLoginTime(t);
		list.add(user);
		user = new UserBean();
		user.setUserID("456");
		user.setUserName("pingping");
		list.add(user);
		
		map.put("data", list);
		map.put("total", 100);
		JSONSerializer serializer = new JSONSerializer();
		serializer.transform(new DateTransformer("yyyy-MM-dd'T'HH:mm:ss"), Date.class);
		serializer.transform(new DateTransformer("yyyy-MM-dd'T'HH:mm:ss"), Timestamp.class);
		System.out.println(serializer.include("data").serialize(map));
		//System.out.println(serializer.deepSerialize(map));
	}

}
